{% extends "base.html" %}

{% block title %}问题反馈管理 - 风之宿{% endblock %}

{% block content %}
<div class="container mx-auto px-4 py-8">
  <h1 class="text-3xl font-bold text-primary mb-8">问题反馈管理</h1>

  <div class="bg-white rounded-lg shadow-md overflow-hidden">
    <div class="overflow-x-auto">
      <table class="min-w-full divide-y divide-gray-200">
        <thead class="bg-gray-50">
          <tr>
            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">用户</th>
            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">标题</th>
            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">提交时间</th>
            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">状态</th>
            <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">操作</th>
          </tr>
        </thead>
        <tbody class="bg-white divide-y divide-gray-200">
          {% for feedback in feedbacks %}
          <tr>
            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ feedback.username }}</td>
            <td class="px-6 py-4">
              <div class="text-sm font-medium text-gray-900">{{ feedback.title }}</div>
              <div class="text-sm text-gray-500 line-clamp-1">{{ feedback.description }}</div>
            </td>
            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">{{ feedback.created_at }}</td>
            <td class="px-6 py-4 whitespace-nowrap">
              <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
                {% if feedback.status == 'resolved' %}bg-green-100 text-green-800
                {% elif feedback.status == 'processing' %}bg-blue-100 text-blue-800
                {% else %}bg-yellow-100 text-yellow-800{% endif %}">
                {{ feedback.status }}
              </span>
            </td>
            <td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
              <form method="POST" action="{% url 'hotel_admin:update_feedback_status' feedback.id %}" class="inline">
    {% csrf_token %}
                <select name="status" onchange="this.form.submit()"
                        class="text-sm border border-gray-300 rounded focus:outline-none focus:ring-primary focus:border-primary">
                  <option value="pending" {% if feedback.status == 'pending' %}selected{% endif %}>待处理</option>
                  <option value="processing" {% if feedback.status == 'processing' %}selected{% endif %}>处理中</option>
                  <option value="resolved" {% if feedback.status == 'resolved' %}selected{% endif %}>已解决</option>
                </select>
              </form>
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}